using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using BlogKickStart.Models.Mapping;
using System.ComponentModel.Composition;

namespace BlogKickStart.Models
{
    [Export(typeof(BlogKickstartContext))]
	public class BlogKickstartContext : DbContext
	{
		static BlogKickstartContext()
		{
			Database.SetInitializer<BlogKickstartContext>(null);
		}

		public BlogKickstartContext()
			: base("Name=BlogKickstartContext")
		{
		}

		public DbSet<Blog> Blogs { get; set; }
		public DbSet<Post> Posts { get; set; }
		public DbSet<Style> Styles { get; set; }
		public DbSet<User> Users { get; set; }
		public DbSet<Comment> Comments { get; set; }

		protected override void OnModelCreating(DbModelBuilder modelBuilder)
		{
			modelBuilder.Configurations.Add(new BlogMap());
			modelBuilder.Configurations.Add(new PostMap());
			modelBuilder.Configurations.Add(new StyleMap());
			modelBuilder.Configurations.Add(new UserMap());
			modelBuilder.Configurations.Add(new CommentMap());
		}
	}
}
